#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <stdlib.h>

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"

#define DEBUG 0
#define NOISY_TEST 1

int checkSmithyEffect(int currentPlayer, int card, struct gameState *state);

int checkSmithyEffect(int currentPlayer, int card, struct gameState *state){

    int i;
    int r;

    int handPos = floor(Random() * state->handCount[currentPlayer]);

    struct gameState pre;
    memcpy (&pre, state, sizeof(struct gameState));

    r = smithyCard(*state, currentPlayer, handPos);

    //Add 3 Cards to deck
    for (i = 0; i < 3; i++)
        {
          drawCard(currentPlayer, &pre);
        }

    //discard card from hand
    discardCard(handPos, currentPlayer, &pre, 0);

    assert (r == 0);
    assert(memcmp(&pre, state, sizeof(struct gameState)) == 0);

	return 0;
}

int main () {
    int currentPlayer;

    struct gameState g;

    printf ("Testing Smithy Card Effect.\n");

    g.whoseTurn = floor(Random() *MAX_PLAYERS);
    currentPlayer = g.whoseTurn;
    g.deckCount[currentPlayer] = floor(Random() * MAX_DECK);
    g.discardCount[currentPlayer] = floor(Random() * MAX_DECK);
    g.handCount[currentPlayer] = floor(Random() * MAX_HAND);
    g.playedCardCount = floor(Random() * MAX_DECK);

    checkSmithyEffect(currentPlayer, smithy, &g);

    printf("Smithy card OK\n");

    return 0;
}
